class Solution {
public:
    string multiply(string num1, string num2) {
        if (num1 == "0" || num2 == "0") {
            return "0";
        }
        int m=num1.size(),n=num2.size();
        vector<int> v(m+n,0);
        string ret;
       for(int i=m-1;i>=0;i--)
       {
        for(int j=n-1;j>=0;j--)
        {
            int mul=(num1[i]-'0')*(num2[j]-'0');
            int sum=mul+v[i+j+1];

            v[i+j+1]=sum%10;
            v[i+j]+=sum/10;
        }
       }
       
       for(int num:v)
       {
        if(!(ret.empty()&&num==0))
        {
            ret.push_back(num+'0');
        }
       }
        return ret.empty()?"0":ret;
    }
};